#!/usr/bin/python3.7
# -*- coding: utf-8 -*-
# @Time : 2019/2/27 0027
# @Email : jtyoui@qq.com
"""
装饰器
"""
from functools import wraps

from flask import session, redirect, url_for


def login_required(func):  # 装饰器.检查是否要登陆
    @wraps(func)
    def wrapper(*args, **kwargs):
        if session.get('user_id'):
            return func(*args, **kwargs)
        else:
            return redirect(url_for('login'))

    return wrapper
